package com.sjn.Client;

import com.sjn.cpu.CPUcomposingRoom;

import java.util.Scanner;



public class cpustart implements StartService{
    CPUcomposingRoom  cpUcomposingRoom = null;
    //收集框架
    String fr =null;
    //收集蓝图
    String bp = null;
    //制作
    String m = null;
    Scanner sc=new Scanner(System.in);
    @Override
    public String toString() {
        return "CPU{" +
                ", 框架='" + fr + '\'' +
                ", 蓝图='" + bp + '\'' +
                ", 制作情况='" + m + '\'' +
                '}';
    }
    @Override
    public void start(int proess){
        //--------------------代工厂start----------------------
        while(proess==1){
            System.out.println("-----进入芯片制作界面-----");
            System.out.println("-----按1选择芯片代工厂-----");
            System.out.println("-----按2选择芯片蓝图-----");
            System.out.println("-----按3构造芯片框架------");
            System.out.println("-----按4选择进行芯片制作-----");
            System.out.println("-----按5结束制作进程------");
            int cpuproess = sc.nextInt();
            if (cpuproess==5){
                System.out.println("芯片制作结束!");
                break;
            }


            while(cpuproess == 1){
                //搭建cpu
                //创建子线程用于选择代工厂
                System.out.println("-----按1选择台积电------");
                System.out.println("-----按2选择中芯国际------");
                int cpuproesss = sc.nextInt();
                cpUcomposingRoom = new CPUcomposingRoom();
                System.out.println("选择:" + cpUcomposingRoom.Foundry(cpuproesss));
                break;
            }
            //--------------------代工厂end----------------------
            //--------------------蓝图start----------------------
            while (cpuproess==2){
                if (cpUcomposingRoom==null){
                    System.out.println("添加失败,请先选择代工厂");
                    break;
                }
                System.out.println("------进入蓝图制作界面------");
                System.out.println("------请依次输入整数x y 以及需要的技术:");
                bp =  cpUcomposingRoom.Blueprint(sc.nextInt(),sc.nextInt(),sc.nextLine());
                System.out.println(bp);
                if (bp!=null){
                    break;
                }

            }
            //--------------------蓝图end----------------------
            //--------------------制作start----------------------
            while (cpuproess==4){
                if (cpUcomposingRoom==null){
                    System.out.println("添加失败,请先选择代工厂");
                    break;
                }
                System.out.println("------进入制作界面,cpu工厂自动制作-----");
                m = cpUcomposingRoom.Production();
                System.out.println(m);
                break;
            }
            //--------------------制作end----------------------
            //--------------------框架start----------------------
            while (cpuproess==3){

                System.out.println("-----请按1添加基础架构-----");
                System.out.println("-----请按2添加寄存器-----");
                System.out.println("-----请按3添加控制器-----");
                System.out.println("-----请按4添加运算器-----");
                System.out.println("-----请按5添加时钟-----");
                System.out.println("-----请按6结束添加-----");
                int cpuproesss = sc.nextInt();

                if (cpUcomposingRoom==null){
                    System.out.println("添加失败,请先选择代工厂");
                    break;
                }
                else if (cpuproesss==1&&cpUcomposingRoom!=null){
                    fr = ""+cpUcomposingRoom.Frameworks(cpuproesss);
                    System.out.println(fr);
                }
                else if (cpuproesss==2&&cpUcomposingRoom!=null){
                    String s =cpUcomposingRoom.Frameworks(cpuproesss).replace("基本架构"," ");
                    fr = fr+""+s;

                    System.out.println(fr);
                }
                else if (cpuproesss==3&&cpUcomposingRoom!=null){
                    String s =cpUcomposingRoom.Frameworks(cpuproesss).replace("基本架构"," ");
                    fr = fr+""+s;

                    System.out.println(fr);
                }
                else if (cpuproesss==4&&cpUcomposingRoom!=null){
                    String s =cpUcomposingRoom.Frameworks(cpuproesss).replace("基本架构"," ");
                    fr = fr+""+s;

                    System.out.println(fr);
                }
                else if (cpuproesss==5&&cpUcomposingRoom!=null){
                    String s =cpUcomposingRoom.Frameworks(cpuproesss).replace("基本架构"," ");
                    fr = fr+""+s;

                    System.out.println(fr);
                }

                if (cpuproesss==6){
                    break;
                }




            }
            //--------------------框架end----------------------

        }

    }
    //返回当前所有数据
}
